<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>03如何获取kindeditor中的值</title>
		<!-- 添加kindeditor的引用 -->
		<script type="text/javascript" charset="utf-8" src="js/kindeditor/kindeditor.js"></script>
		<script type="text/javascript" charset="utf-8" src="js/kindeditor/lang/zh_CN.js"></script>
	</head>
	
	<script>
		var editor;
		KindEditor.ready(function(K){
			editor = K.create('textarea[id="content"]',{
				allowFileManager : true,
				//设置编辑器为简单模式
				items:[
					'fontname','fontsize','i','forecolor','hilitecolor','bold','italic','underline',
					'removeformat','i','justifyleft','justifycenter','justifyright','insertorderedlist',
					'insertunorderedlist','i','emoticons','image','link'
				],
				//这行代码就是关键所在，当失去焦点时执行this.sync()
				afterBlur : function() {
					this.sync();//这个函数就是同步kindeditor的值到textarea文本框
				}
			});
		});
		//获取kindeditor中的值
		function showKindeditor(){
			//获取textarea中的值并在div中展示
			document.getElementById("showKindeditor").innerHTML = document.getElementById("content").value;
		}
	</script>
	
	<body>
		<div style="width:38%;height: 500px;border: 1px solid black;float: left;display: inline-block;">
			<div id="showKindeditor" style="width:100%;height: 70%;"></div>
			<button onclick="showKindeditor()">显示kindeditor中的值</button>
		</div>
		<textarea id="content" style="width:60%;height: 500px;"></textarea>
	</body>
</html>
